# 项目名称：获取复仇者联盟4：终局之战电影信息

from bs4 import BeautifulSoup

html = '''
      <h1>
      <span property="v:itemreviewed">复仇者联盟4：终局之战 Avengers: Endgame</span>
          <span class="year">(2019)</span>
      </h1>
      <span><span class="pl">导演</span>
      ':' 
        <span class="attrs">
          <a href="/celebrity/1321812/" rel="v:directedBy">安东尼·罗素</a>
          / 
          <a href="/celebrity/1320870/" rel="v:directedBy">乔·罗素</a>
        </span>
      </span>
      <span><span class="pl">编剧</span>
      ':' 
        <span class="attrs">
          <a href="/celebrity/1276125/">克里斯托弗·马库斯</a>
          / 
          <a href="/celebrity/1276126/">斯蒂芬·麦克菲利</a> 
          / 
          <a href="/celebrity/1013888/">斯坦·李</a> 
          / 
          <a href="/celebrity/1050183/">杰克·科比</a> 
          / 
          <a href="/celebrity/1360715/">吉姆·斯特林</a>
        </span>
      </span>
      <span class="actor">
        <span class="pl">主演</span>
        ':' 
        <span class="attrs">
          <span><a href="/celebrity/1016681/" rel="v:starring">小罗伯特·唐尼</a> / </span>
          <span><a href="/celebrity/1017885/" rel="v:starring">克里斯·埃文斯</a> / </span>
          <span><a href="/celebrity/1040505/" rel="v:starring">马克·鲁弗洛</a> / </span>
          <span><a href="/celebrity/1021959/" rel="v:starring">克里斯·海姆斯沃斯</a> / </span>
          <span><a href="/celebrity/1004568/" rel="v:starring">乔什·布洛林</a> / </span>
        </span>
      </span>
      '''
bs = BeautifulSoup(html, 'html.parser')

movie_name = bs.find('span', property="v:itemreviewed").text

director = []
director_list = bs.find_all('a', rel="v:directedBy")
for i in director_list:
    director.append(i.text)

actor = []
actor_list = bs.find_all('a', rel="v:starring")
for i in actor_list:
    actor.append(i.text)

movie_dict = {'电影名':movie_name,'导演':director,'主演':actor}
print(movie_dict)